﻿using System;
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.Web.DynamicData;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NotAClue.Web.DynamicData;

namespace DD_Extensions
{
    public partial class BooleanField : System.Web.DynamicData.FieldTemplateUserControl
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            // add tool-tip
            this.SetupTip();

            // add CSS from meta data
            this.ApplyCss();
        }

        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            object val = FieldValue;
            if (val != null)
                CheckBox1.Checked = (bool)val;

            this.HighlightRow();
        }

        public override Control DataControl
        {
            get { return CheckBox1; }
        }
    }
}